﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.SqlClient;
using System.Data;
using System.Configuration;
using SMODEL;

namespace SDAL
{
    public class Users_dal
    {
        string strConn = ConfigurationManager.ConnectionStrings["myDB"].ToString();

        public List<Users_model> GetList()
        {
            string str = "SELECT * FROM Users";
            SqlConnection conn = new SqlConnection(strConn);
            conn.Open();
            SqlCommand cmd = new SqlCommand(str, conn);
            List<Users_model> li = new List<Users_model>();
            SqlDataReader reader = cmd.ExecuteReader();
            while (reader.Read())
            {
                Users_model u = new Users_model();
                u.UserId = Convert.ToInt32(reader["UserId"]);
                u.UserName = reader["UserName"].ToString();
                u.UserPwd = reader["UserPwd"].ToString();
                u.RoleId = Convert.ToInt32(reader["RoleId"]);
                li.Add(u);
            }
            return li;
        }
    }
}
